import { createStore } from 'vuex'

const store = createStore({
	strict: true,
	state: {
		navBarHeight: 0,
		statusBarHeight: 0
	},
	mutations: {
		clacNavHeight(state){
			
			// 获取状态栏高度
			const statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
			// 小程序下 获取按钮的 位置和高度
			// #ifdef MP-WEIXIN
			// 获取胶囊按钮的高度
			const {top, height} = uni.getMenuButtonBoundingClientRect();
			const navBarHeight = (top-statusBarHeight)*2 + height + statusBarHeight;
			// #endif
			// #ifdef APP
			const navBarHeight = statusBarHeight + 40;
			// #endif
			state.navBarHeight = navBarHeight;
			state.statusBarHeight = statusBarHeight;
		}
	}
})

export default store